package com.wlzg.collectiontool.db

import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import com.wlzg.collectiontool.App
import com.wlzg.collectiontool.model.bean.*
import com.wlzg.collectiontool.model.bean.PsHuafenchi

@Database(entities = [User::class,PsJin::class,PsXiangmu::class,PsGongcheng::class,
    PsXiaoqu::class,PsDaolu::class,
                     PsHuafenchi::class,PsLiguan::class,Psyushuikou::class,
                     Pspfk::class,PsGuanxian::class
                     ,LoginresSt::class,Muser::class],version = 1,exportSchema = false)
abstract class AppDatabase : RoomDatabase() {
    abstract fun userDao(): UserDao
    companion object {
        private var instance: AppDatabase? = null
        fun getInstance(): AppDatabase {
            if (instance == null) {
                instance = Room.databaseBuilder(
                    App.mContext!!,
                    AppDatabase::class.java,
                    "user.db" //数据库名称
                ).allowMainThreadQueries().build()
            }
            return instance as AppDatabase
        }
    }

}